<?php

/**
 * Created by PhpStorm.
 * User: evan
 * Date: 2017/3/6
 * Time: 下午9:43
 */
class Common extends MY_Www_Controller
{
    public function apply()
    {
        $realname = trim($this->input->get_post('realname'));
        $mobile   = trim($this->input->get_post('mobile'));
        $area     = trim($this->input->get_post('area'));
        $content  = trim($this->input->get_post('content'));


        if (empty($realname) || empty($mobile) || empty($area) || empty($content))
        {
            show_error('参数不全!');
        }


        $item = array
        (
            'realname' => $realname,
            'mobile'   => $mobile,
            'area'     => $area,
            'content'  => $content,
            'ip'       => $this->input->ip_address(),
        );


        $this->load->model('agent/Model_agent_apply', 'ap');
        $save_rs = $this->ap->save($item);
        if (!$save_rs)
        {
            show_error('保存申请失败!');
        }


        echo '<script>alert("保存申请成功!");window.location.href="/Business/index";</script>';
        exit;
    }
}